var sequentialDuration = 300;
var canOpenToolbar = true;

/****
 *
 * Application start Up
 *
 * **/

function startApp() {

	$('#application_header').fadeIn(1000, addDashboardAnimation);
	initializeComponents();
}

/****
 *
 * Components initialization
 *
 * **/

function initializeComponents() {

	// Dash board todo lists
	$("#sortable_today, #sortable_week, #sortable_month,#sortable_year").sortable({
		connectWith : ".connectedSortable",
		placeholder : "ui-state-highlight",
		forcePlaceHolderSize : true,
		cursor : "pointer",
		distance : 20
	}).disableSelection();

	$("#search_container button:first").button({
		icons : {
			primary : "ui-icon-search"
		}
	}).click(function() {
		//alert("new");
	});
	//After all components are initialized, add the handlers
	prepareHandlers();
}

/****
 *
 * Adding Handlers
 *
 * **/

function prepareHandlers() {

	// var $win = $(window);
	//
	// $win.scroll(function() {
	// if($win.scrollTop() == 0)
	// $('.toolbar').slideDown(300);
	// else {
	// $('.toolbar').slideUp(300);
	// ;
	// }
	// });

}

function addDashboardAnimation() {
	$("#today").fadeIn(sequentialDuration, function() {
		$("#week").fadeIn(sequentialDuration, function() {
			$("#month").fadeIn(sequentialDuration, function() {
				$("#year").fadeIn(sequentialDuration, function() {

					$("#application_footer").fadeIn(sequentialDuration);
				});
			});
		});
	});
}